<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>JavaScript 数组方法 </title>
</head>
<body>
<h2>更改元素</h2>
<p>通过使用它们的索引号来访问数组元素:数组索引（下标）以 0 开始。[0] 是第一个数组元素，[1] 是第二个，[2] 是第三个 ...</p>

<p id="demo1"></p>
<p id="demo2"></p>

<script>
  var fruits = ["Banana", "Orange", "Apple", "Mango"];
  document.getElementById("demo1").innerHTML = fruits;
  fruits[0] = "Lemon";
  //或 fruits[fruits.length] = "Kiwi";          // 向 fruits 追加 "Kiwi"，结果Banana,Orange,Apple,Mango,Lemon
  document.getElementById("demo2").innerHTML = fruits;
</script>

</body>
</html>

<!--
运行结果：
Banana,Orange,Apple,Mango

Lemon,Orange,Apple,Mango
-->